package thread;

/**
 * @Author: Miyako
 * @Date: 2024-07-19-14:37
 * @Description: 多线程测试
 */


class MyThread01  implements Runnable{//重写任务里的run方法
    public void run() {
        String tName=Thread.currentThread().getName();
        while(true) {
            System.out.println( tName+ "->MyThread01.run()");
        }
    }
}
    class MyThread02 implements Runnable{
        public void run() {
            String tName=Thread.currentThread().getName();
            while(true) {
                System.out.println( tName+ "->MyThread02.run()");
            }
        }
    }
public class MyThreadDemo01 {
    public static void main(String[] args) {


    MyThread01 tas1 = new MyThread01();
    MyThread02 tas2 = new MyThread02();
    Thread t1 = new Thread(tas2);
    Runnable task = () -> System.out.println("1");
    Runnable tAsk = ()->{System.out.println(1);};

    task.run();
    Thread t2 = new Thread(tas1);
    Thread t3 = new Thread(()->{
        String tName=Thread.currentThread().getName();
        while(true) {
            System.out.println( tName+ "->MyThread01.run()");
        }});
    t1.start();
    t2.start();
    t3.start();

    }

}
